import {Notification} from 'element-ui';
import config from "@/config/index"
/**
 * [notifySuccess 成功提示]
 * @param  {[String]} msg [提示内容]
 */
export const notifySuccess = (msg) => {
  Notification({
     title: '成功',
     message: msg,
     type: 'success'
   });
}

/**
 * [notifyError 失败提示]
 * @param  {[String]} msg [提示内容]
 */

export const notifyError = (msg) => {
  Notification({
     title: '错误',
     message: msg,
     type: 'error'
   });
}
/**
 * [notifyError 图片转换路径]
 * @param  {[String]} img [图片地址]
 */
export const getImg = (img) => {

  try {
    let arr = JSON.parse(img);
    if (arr.length > 0) {

      if (img.indexOf("statics.seatent.com") != -1 || img.indexOf("http://") || img.indexOf("https://")) {
        return JSON.parse(img)[0];
      } else {
        return config.imgUrl + JSON.parse(img)[0];
      }
    } else {
      return "";
    }
  } catch (e) {
    if (img.indexOf("statics.seatent.com") != -1 || img.indexOf("http://")  || img.indexOf("https://")) {
      return img;
    } else {
      return config.imgUrl + img;
    }
  }
}
export const isNumber = (val)=> {
    var regPos = /^\d+(\.\d+)?$/; //非负浮点数
    var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
    if(regPos.test(val) || regNeg.test(val)) {
        return true;
    } else {
        return false;
    }
}
